#include "StdAfx.h"
/// Copyright 2012, Alex Averian, Yonan Research
/// Released under BSD Licence



#include "..\qcom.h"
using namespace micro::com;


#include "qdirectwrite.h"
using namespace micro::directx;



//
// Get a DirectWrite factory
//
HRESULT QDirectWrite::GetDWriteFactory( IDWriteFactory** factory )
{
    if ( nullptr == factory )
        return E_POINTER;
        
    static QComPointer<IDWriteFactory> m_pDWriteFactory;
    HRESULT hr = S_OK;
    
    if ( nullptr == m_pDWriteFactory )
    {
        hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof( m_pDWriteFactory ), reinterpret_cast<IUnknown**>( &m_pDWriteFactory ) );
    }
    
    if ( SUCCEEDED( hr ) )
    {
        *factory = m_pDWriteFactory;
        ( *factory )->AddRef();
    }
    
    return hr;
}




 